package datastructure.queue;

import java.util.Stack;

/**
 * @Author ZhangCuirong
 * @Date 2025/8/13 15:25
 * @description:
 */
public class MyQueue {
    Stack<Integer> mainStack;
    Stack<Integer> helpStack;
    int size;
    public MyQueue() {
        size = 0;
        mainStack = new Stack<>();
        helpStack = new Stack<>();
    }

    public void push(int x) {
        while (!mainStack.isEmpty()){
            helpStack.push(mainStack.pop());
        }
        helpStack.push(x);
        while (!helpStack.isEmpty()){
            mainStack.push(helpStack.pop());
        }
        size++;

    }

    public int pop() {
        size--;
        return mainStack.pop();
    }

    public int peek() {
        return mainStack.peek();

    }

    public boolean empty() {
        return size == 0;
    }
}
